package com.example.utils;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import com.example.tetris.R;

import java.util.Random;

public class Constants {
    //定义每个方格的尺寸
    public  static final int SIZE = UIUtils.dp2px(30);
    public  static final int ROW = 20;
    public  static final int COLUMN = 10;

    private static Bitmap defaultBitmap ;

    //提供给外部一个默认的资源（方块的颜色将在触底后合并时统一）
    public static Bitmap getDefaultBitmap(Context context){
        if (defaultBitmap == null){
            defaultBitmap = BitmapFactory.decodeResource(context.getResources(),R.drawable.blue);
        }
        return defaultBitmap;
    }

    //获取随机图片资源
    private static int[] images = {R.drawable.blue
    ,R.drawable.yellow,R.drawable.purple,R.drawable.green,R.drawable.red};

    public static int getRandomImageRes(){
        Random random = new Random();
        int index = random.nextInt(images.length);
        return images[index];
    }
}
